
from fastapi.middleware.cors import CORSMiddleware
import logging

def init_app(app):
    # 允许的源
    origins = [
        "http://localhost:3000"
    ]

    app.add_middleware(
        CORSMiddleware,
        allow_origins=origins,
        allow_credentials=True,
        allow_methods=["*"],      # 或者指定具体的方法 ['GET', 'POST']
        allow_headers=["*"],      # 或者指定具体的 header
    )

    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s - %(levelname)s - %(message)s',
                        handlers=[
        logging.StreamHandler(),
        logging.FileHandler("app.log")
    ])
              